
#ifndef LOD_ERROR_H
#define LOD_ERROR_H

#include <string>

//! Error
class error
{
    public:
    //! Error codes
    enum codes 
    {
        OK=0,
        ERROR_couldnot_open_file,
        ERROR_file_IO, 
        ERROR_EOF,
        ERROR_file_line_too_long,
        ERROR_wrong_data, 
        ERROR_internal_istringstream,
        ERROR_bad_vertex_in_triangle,
        ERROR_bad_material_in_triangle,
        ERROR_mem_lack,
        ERROR_ply_failed,
        ERROR_unsupported_format,
    };

    /*!
     * \param c Code
     * \param line_nr The bad line's number*/
    error(codes c, int line_nr=-1)
     : code(c), bad_line(line_nr)
    {
    }

    error()
     : code(error::OK)
    {
    }

    /*!
     * \return Description of the error.*/
    //todo
    //const char* get_desc()
    std::string get_desc()
    {
        return std::string(descriptions[code]);
        //return descriptions[code];
    }

    //! Code of the error
    int get_code()
    {
        return code;
    }

    //! Line number where the error has occured
    int get_linenr()
    {
        return bad_line;
    }

    //static std::string get_desc(int code)
    //{
    //    return std::string(descriptions[code]);
    //}

    //! Error's code.
    codes code;
    //! Number of a bad line (the line where the error has occured).
    int bad_line;
    //! Descriptions of errors.
    /*! They are associated with the error codes.*/
    static const char* descriptions[];
};


#endif
